<?php

declare(strict_types=1);

namespace Plugin\Attractions\AttractionManagement\Model;

use Hyperf\Database\Model\SoftDeletes;
use Hyperf\DbConnection\Model\Model as MineModel;

/**
 * @property string $id 用户ID
 * @property string $username 用户名
 * @property string $avatar 用户头像
 * @property int $times 用户登录次数
 * @property \Carbon\Carbon $created_at 
 * @property \Carbon\Carbon $updated_at 
 */
class AttractionUser extends MineModel
{
    use SoftDeletes;
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'attraction_user';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'username', 'avatar', 'times', 'open_id'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = [
        'id' => 'integer',
        'times' => 'integer',
        'created_at' => 'datetime',
        'updated_at' => 'datetime'
    ];

    public function bookings()
    {
        return $this->hasMany(AttractionUserBooking::class, 'user_id', 'id');
    }

    public function touristInfos()
    {
        return $this->hasMany(AttractionUserTouristInfo::class, 'user_id', 'id');
    }
}